iT邦幫忙

2

Apache 問題詳解

  • 分享至 

  • xImage
  •  

開啟 Apache 狀態功能

在 httpd.conf 裡面,

開放以下模組功能
LoadModule status_module modules/mod_status.so

加入以下設定
<Location "/server-status">
SetHandler server-status
Require ip 10.99.1.123
</Location>

透過此連結可看到系統資訊
http://127.0.0.1/server-status?refresh=10

常用指令

查看 Apache 版本資訊
/usr/local/apache_2.4.65/bin/httpd -V

計算 Apache 總記憶體使用量
ps aux | grep 'httpd' | awk '{ total += $6; } END { print total/1024"MB" }'

計算 Apache 總 CPU 使用量
ps aux | grep 'httpd' | awk '{ total += $3; } END { print total"%" }'

查看當前正在運行的 Apache 進程數
ps faux|grep 'httpd' |wc -l

查看所有進程下運行的 Apache 線程總數, MaxRequestWorkers的設定值需大於此值
ps -eLf|grep 'httpd' |wc -l

查看在特定 Apache 進程下運行的線程數
ps -eLf|grep $程序編號 |wc -l

查看當前的連接數狀況
netstat -nat|awk '{print awk $NF}'|sort|uniq -c|sort -n

linux 下獲取佔用 CPU 資源最多的 10 個進程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

linux 下獲取佔用內存資源最多的 10 個進程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head

列出系統上最耗費記憶體的程式
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

前 10 個最耗費記憶體的行程
top -b -o +%MEM | head -n 17

找出最耗費 CPU 資源的行程
top -b -o +%CPU | head -n 17

查看和 Apache 相關的連線
netstat -ae|grep www-data

查看目前連線數最高的IP
netstat -nat|grep ":80"|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言